<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

    </style>
</head>
<body>
<div>这是div</div>
<input type="text">
<input type="button" value="按钮" onclick="f()">
</body>

<script>
    function f(){
        //得到div和文本框
        let d = document.querySelector("div")
        let i = document.querySelector("input")
        //把文本框的值取出赋值给div
        d.innerText = i.value;
    }
</script>

</html>